package base;

public class copyArrary {
    public static void main(String[] args) {
        int [] arr = {1,2,3,4,5,6,7,8,9};
        int[] copyarr1 = copyarr(arr,1,5);
        for (int i = 0; i < copyarr1.length; i++) {
            System.out.print(copyarr1[i]+",");
        }

    }
    public static int[] copyarr(int[] arr,int from,int to){  //{2,3,4,5}
        int [] newarr = new int [to-from];  //{index...} 数组名newarr
        int index = 0;
        for (int i = from; i < to; i++) { //1~5
            newarr[index] = arr[i];
            index++;
        }
        return newarr;  //返回int[] newarr
    }

}
